<template>
	<view style="padding-top: 20px;">
		<view class="wrapper">
			<view class="infotop">
				<image :src="userinfo.avatar"></image>
			</view>
			<view class="infotext" >
				<text class="textname">{{userinfo.nickname}}</text>
				<text class="textphone">视信号：{{userinfo.account}}</text>
			</view>
		</view>
		<view class="scontent">
<!-- 			<view class="card" @click="gobeizhu">
				<text class="tit"  >备注</text>
			</view> -->
			<view class="card" @click="gofenxiang">
				<text class="tit">分享名片</text>
			</view>
			<view class="fltwo"  @click="gopengyouquan">
				<view class="tit">云发布</view>
				<image src="/static/images/next.png"></image>
				
			</view>
			
			<view v-if="isshow" class="" style="height: 40px;display: flex;align-items: center;border-bottom: 1px solid #eee;">
				<text class="tit">加入黑名单</text>
			</view>
			<view  class="fltwo"  style="border-bottom: 1px solid #eee;">
				<text class="tit">进群方式</text>
				<text class="yaoqing">{{fangshi}}</text>
				</text>
			</view>
			<view class="fltwo" @click="shagnxaifen" v-show="myname==qunguanli">
				<text class="tit">上下分</text>
				<image src="/static/images/next.png"></image>
			</view>
			<view class="bottomtext" v-show="isfriend==1">
				<text @click="gomess">发送消息</text>
			</view>
			<view v-show="isfriend==0" @tap="addfriend" class="tjhaoyou">
				<text>添加好友</text>
			</view>



		</view>
	</view>
</template>

<script>
	var WebIM = require("../../utils/WebIM")["default"];
	export default {
		data() {
			return {
				token:'',
				isshow:false,
				uid:'',
				userinfo:{},
				isfriend:'',
				friend_name: "",
				account:'',
				name:'',
				qid:'',
				fangshi:'',
				q_id:'',
				myname:'',
				qunguanli:'',
			}
		},
		methods: {
			// 获取用户信息
			getuserinfo(){
				console.log(this.account)
				uni.request({
					url:this.G_base + '/api/lz/huinfo',
					method:'POST',
					header: {
						'content-type': 'application/x-www-form-urlencoded',
						'Authori-zation': 'Bearer ' + this.token
					},
					data:{
						account:this.account,
						qid:this.qid
					},
					success:res=>{
						console.log(res)
						this.userinfo=res.data.data.data
						this.isfriend=res.data.data.data.is_hy
						this.friend_name=res.data.data.data.account
						this.fangshi = res.data.data.data.fangshi
						console.log(this.friend_name)
					}
				})
			},
			//上下分
			shagnxaifen(){
				uni.navigateTo({
					url:'/pages/qunfen/gerenfen?account='+this.userinfo.account+"&q_id="+this.q_id+"&roomid="+this.qid
				})
			},
			// 添加好友
			addfriend(){
				let message ="请求添加好友!"
				WebIM.conn.addContact(this.userinfo.account, message);
				uni.showToast({
					title:"请求已发送",
					icon:'none'
				})
				setTimeout(()=>{
					uni.navigateBack({
						
					})
				},1000)
			},
			isExistFriend(name, list) {
				for (let index = 0; index < list.length; index++) {
					if (name == list[index].name) {
						console.log("已经是你的好友了")
						return true
					}
				}
				
				console.log("不是你的好友请添加")
				return false
			},
			gobeizhu(){
				uni.navigateTo({
					url:"../beizhu/beizhu?nickname="+this.userinfo.nickname
				})
			},
			gofenxiang(){
				uni.navigateTo({
					url:"../mine/mycode/mycode"
				})
			},
			gomess(){
				let name = uni.getStorageSync('myUsername')
				var nameList = {
					myName: name,
					your: this.friend_name
				};
				uni.navigateTo({
					url: "../chatroom/chatroom?username=" + JSON.stringify(nameList)
				});
			},
			test(){
				uni.navigateBack({
					delta:1
				})
			},
			goback() {
				console.log("Fanhu")
				uni.navigateBack({
					delta:1
				})
			},
			upfen(){
				uni.navigateTo({
					url:"../friendt/friendt"
				})
			},
			gopengyouquan(){
				uni.navigateTo({
					url:"../notification/friend_notification?name="+this.userinfo.account
				})
			}
		},
		onLoad(data){
			console.log(data.account)
			this.token = uni.getStorageSync("token")
			this.qunguanli = uni.getStorageSync('myUsername')
			this.account = data.account
			this.userinfo.avatar = data.img
			this.qid = data.qid
			this.q_id = data.q_id
			this.myname = data.guanli
			this.getuserinfo()
			// this.uid=data.uid
			// this.token=uni.getStorageSync('token')
			// this.getuserinfo()
		},
	}
</script>
<style>
	.bottomtext{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-top: 50upx;
	}
	.bottomtext text{
		width: 100%;
		height: 80upx;
		line-height: 80upx;
		text-align: center;
		color: rgba(16, 16, 16, 1);
		font-size: 16px;
	}
	.tjhaoyou{
		width: 100%;
		height: 80upx;
		text-align: center;
		line-height: 80upx;
		margin-top: 50upx;
		font-size: 16px;
	}
	.tit{
		width: 100%;
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
	}
	.fenshu{
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		text-align: left;
		font-family: Microsoft YaHei;
		margin-left: 100px;
	}
	.yaoqing{
		color: rgba(16, 16, 16, 1);
		font-size: 14px;
		font-family:Microsoft YaHei;
		width: 100%;
	}
	.scontent{
		width: 100%;
		padding:0 35upx ;
		box-sizing: border-box;
		margin-top: 20upx;
	}
	.card{
		height: 50px;
		border-bottom: 1px solid #eee;
		line-height: 40px;
		margin-bottom: 20upx;
	}
	.fltwo {
		height: 50px;
		border-bottom: 1px solid #eee;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.fltwo image{
		width: 55upx;
		height: 55upx;
	}

	.wrapper .infotext {
		display: flex;
		flex-direction: column;
		line-height: 55upx;
		margin-left: 20upx;
	}
	.textphone{
		font-size: 15px;
		color: #999;
	}

	.wrapper {
		width: 100%;
		padding:0 35upx ;
		box-sizing: border-box;
		display: flex;
		align-items: center;
	}

	.infotop image {
		width: 60px;
		height: 60px;
		border-radius: 80px;
	}
</style>
